<?php

namespace app\common\model\blacklist;

use app\common\model\User;
use think\Model;


class UserBlacklist extends Model
{


    // 表名
    protected $name = 'user_blacklist';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'user_name',
        'to_user_name',
    ];

    public function getUserNameAttr($value, $data)
    {
        return User::where('id', $data['user_id'])->cache(60)->value('nickname');
    }

    public function getToUserNameAttr($value, $data)
    {
        return User::where('id', $data['to_user_id'])->cache(60)->value('nickname');
    }

}
